<?php
/**
 * SEO管理
 *
 */
class Model_Seo {
	function __construct() {
		$this->view = Zend_Registry::get ( 'Smarty' );
	}
	
	/**
	 * 页面SEO设置
	 *
	 * @param $title string       	
	 * @param $title_format string       	
	 * @param $description string       	
	 * @param $keyword string       	
	 */
	function setPageSeoInfo($t, $t_format = null, $page_description = null, $page_keywords = null) {
		if ($page_description) {
			$this->view->assign ( 'page_description', strip_tags ( trim ( $page_description ) ) );
		}
		
		if ($page_keywords) {
			$this->view->assign ( 'page_keywords', strip_tags ( trim ( $page_keywords ) ) );
		}
		$this->setPageTitle ( $t, $t_format );
	}
	
	/**
	 * 设置网页标题
	 *
	 * @param $_title unknown_type       	
	 * @param $format string       	
	 */
	function setPageTitle($_title = null, $format = null) {
		if (! $format) {
			$format = "T - S";
		}
		
		$pageTitle = str_replace ( "S", "后台管理中心", $format );
		
		if (is_array ( $_title )) {
			foreach ( $_title as $k => $t ) {
				$pageTitle = str_replace ( "T" . $k, $t, $pageTitle );
			}
		} elseif (is_string ( $_title )) {
			$pageTitle = str_replace ( "T", $_title, $pageTitle );
		}
		$this->view->assign ( 'pageTitle', $pageTitle );
	}
}

?>